﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLBS.Entity;
using NHibernate;
using System.Collections.Specialized;
using NHibernate.Cfg;
namespace NLBS.Data
{
    public partial class NHibernateDataProvider : DbProvider
    {
        public ISession CurrentSession { get; set; }


        public override void Initialize(string name, NameValueCollection configValue)
        {
            
            base.Initialize(name, configValue);
        }



        public override string BackUpDatabase(string backuppath, string ServerName, string UserName, string Password, string strDbName, string strFileName)
        {
            return string.Empty;

            //SQLServer svr = new SQLServerClass();
            //try
            //{
            //    svr.Connect(ServerName, UserName, Password);
            //    Backup bak = new BackupClass();
            //    bak.Action = 0;
            //    bak.Initialize = true;
            //    bak.Files = backuppath + strFileName + ".bak";
            //    bak.Database = strDbName;
            //    bak.SQLBackup(svr);
            //    return string.Empty;
            //}
            //catch (Exception ex)
            //{
            //    string message = ex.Message.Replace("'", " ");
            //    message = message.Replace("\n", " ");
            //    message = message.Replace("\\", "/");
            //    return message;
            //}
            //finally
            //{
            //    svr.DisConnect();
            //}


        }

        public override string RestoreDatabase(string backuppath, string ServerName, string UserName, string Password, string strDbName, string strFileName)
        {
            return string.Empty;
            //#region 数据库的恢复的代码

            //SQLServer svr = new SQLServerClass();
            //try
            //{
            //    svr.Connect(ServerName, UserName, Password);
            //    QueryResults qr = svr.EnumProcesses(-1);
            //    int iColPIDNum = -1;
            //    int iColDbName = -1;
            //    for (int i = 1; i <= qr.Columns; i++)
            //    {
            //        string strName = qr.get_ColumnName(i);
            //        if (strName.ToUpper().Trim() == "SPID")
            //        {
            //            iColPIDNum = i;
            //        }
            //        else if (strName.ToUpper().Trim() == "DBNAME")
            //        {
            //            iColDbName = i;
            //        }
            //        if (iColPIDNum != -1 && iColDbName != -1)
            //            break;
            //    }

            //    for (int i = 1; i <= qr.Rows; i++)
            //    {
            //        int lPID = qr.GetColumnLong(i, iColPIDNum);
            //        string strDBName = qr.GetColumnString(i, iColDbName);
            //        if (strDBName.ToUpper() == strDbName.ToUpper())
            //            svr.KillProcess(lPID);
            //    }


            //    Restore res = new RestoreClass();
            //    res.Action = 0;
            //    string path = backuppath + strFileName + ".bak";
            //    res.Files = path;

            //    res.Database = strDbName;
            //    res.ReplaceDatabase = true;
            //    res.SQLRestore(svr);

            //    return string.Empty;
            //}
            //catch (Exception err)
            //{
            //    string message = err.Message.Replace("'", " ");
            //    message = message.Replace("\n", " ");
            //    message = message.Replace("\\", "/");

            //    return message;
            //}
            //finally
            //{
            //    svr.DisConnect();
            //}

            //#endregion
        }

        public override void UpdateCategoryCounter(int catID)
        {
            throw new NotImplementedException();
        }

        public override void UpdateCommentCount(int logID, int authorID)
        {
            throw new NotImplementedException();
        }

    }
}
